package cn.jbt.api.admin.controller;

import cn.jbt.api.admin.annotation.Log;
import cn.jbt.api.admin.service.AliyunOssService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/aliyun/oss")
@Slf4j
@AllArgsConstructor
public class AliyunOssController {

    private final AliyunOssService aliyunOssService;

    /**
     * <h2>文件上传</h2>
     */
    @PostMapping("/upload")
    @Log(bizType = "上传", bizName = "阿里云OSS文件上传")
    public Map<String, Object> upload(@RequestPart("file") MultipartFile file) throws IOException {
        return aliyunOssService.upload(file);
    }
}
